package model.admin;

import java.util.ArrayList;

import myutil.Connect;

import vo.BatchDetailsVo;

public class ModifyBatchDetails {

	public Boolean editBatchDetails(ArrayList<BatchDetailsVo> BatchDetails) {
		String query = "";
		return true;
	}

	public int addBatchDetails(BatchDetailsVo newBatch,String type) {

		String query = "INSERT INTO batch_details " + "(batch_name,"
				+ " start_date, " + "end_date, " + "student_count, "
				+ "start_year, " + "incharge_id, " + "description,status)"
				+ " VALUES ('" + newBatch.getBatch_name() + "'," + " '"
				+ newBatch.getStart_date() + "', " + "'"
				+ newBatch.getEnd_date() + "'," + ""
				+ newBatch.getStudent_count() + "," + ""
				+ newBatch.getStart_year() + ", " + ""
				+ newBatch.getIncharge_id() + "," + " '"
				+ newBatch.getDescription() + "','Active');";
		int result;
		System.out.println(query);
		Connect c = new Connect();
		try {
			c.dml(query);
			c.logger(type, "Insert");
			result = 1;

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result = -1;
		}
		return result;
	}

	public int editBatchDetails(BatchDetailsVo newBatch,String type) {

		String query = "UPDATE batch_details set batch_name="
				+ newBatch.getBatch_name() + "'," + "start_date='"
				+ newBatch.getStart_date() + "', " + "end_date='"
				+ newBatch.getEnd_date() + "'," + "student_count="
				+ newBatch.getStudent_count() + "," + "start_year="
				+ newBatch.getStart_year() + ", " + "incharge_id="
				+ newBatch.getIncharge_id() + "," + "description= '"
				+ newBatch.getDescription() + "';";
		int result ;
		Connect c = new Connect();
		try {
			c.dml(query);
			c.logger(type, "Update");
			result = 1;

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result = -1;
		}
		return result;
	}

	public int deleteBatchDetails(int batch_id,String type) {

//		String query=	"delete " +	
//						  "from student_course" +
//						 "where degree_course_id in (select degree_course_id" +
//						 							  "from degree_course" +
//						 							" where professor_id in (select professor_id" +
//						 												   "from degree_current_year_semester" +
//						 												  "where degree_department_id in (select degree_department_id" +
//						 												  								   "from degree_department " +
//						 												  								  "where batch_id=1)));";

		String query="update batch_details set status=0 where batch_id="+batch_id+";";
		
		int result;
		Connect c = new Connect();
		try {
			c.dml(query);
			c.logger(type, "Update");
			result = 1;

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result = -1;
		}
		return result;
	}

}
